package com.maolong.controller;

import com.maolong.pojo.fuction.result.Result;
import com.maolong.pojo.vo.Top6Product;
import com.maolong.service.IProdDetailService;
import com.maolong.service.IProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "统计")
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    IProductService productService;
    @Autowired
    IProdDetailService prodDetailService;

    /**
     * 获取物品库存量前五名
     * @return
     */
    @GetMapping("/inventory")
    @ApiModelProperty("物品库存量展示")
    public Result product(){
        List<Top6Product> top5Product = productService.getTop5Product();
        return Result.success(top5Product);
    }
    /**
     * 获取出库物品前五名
     * @return
     */
    @GetMapping("/sales")
    @ApiModelProperty("物品销量展示")
    public Result sales(){
        return Result.success(productService.getTop5ProductRemove());
    }

    /**
     * 入库数量展示
     */
    @GetMapping("/add")
    @ApiModelProperty("入库数量展示")
    public Result add(){
        return Result.success(productService.getTop5ProductIn());
    }
    /**
     * 出库数量展示
     */
    @GetMapping("/remove")
    @ApiModelProperty("出库数量展示")
    public Result remove(){
        return Result.success(productService.getTop5ProductOut());
    }

}
